package routers

import (
	"log"
	"dzomc/controllers"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
)

var FilterUser = func(ctx *context.Context) {
	_, ok := ctx.Input.Session("uid").(int)
	if !ok && ctx.Request.RequestURI != "/login" {
		log.Println("filterUser error")
		ctx.Redirect(302, "/login")
	}else{
		log.Println("filterUser ok")
	}
}



func init() {

	beego.InsertFilter("/*", beego.BeforeRouter, FilterUser)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/ws", &controllers.WsController{})
}
